IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntitySpan Class > EntitySpan Constructor : EntitySpan Constructor(Type,EntityRelation[]) |
'Declaration
Public Function New( _ ByVal fromType As Type, _ ByVal ParamArray entityRelations() As EntityRelation _ )
'Usage
Dim fromType As Type Dim entityRelations() As EntityRelation Dim instance As New EntitySpan(fromType, entityRelations)
public EntitySpan( Type fromType, params EntityRelation[] entityRelations )
Exception | Description |
---|---|
System.ArgumentException | Thrown if the relationships are ambiguous or do not connect |
The EntitySpan is used in retrieving an entity graph with EntityManager.FindEntityGraph
public void FindEntityGraph() { DomainModelEntityManager mgr = new DomainModelEntityManager(); // Preload some data into cache for this example. var emp = mgr.Employees.Where(e => e.Id == 1).Include("OrderSummaries.OrderDetails.Product").ToList().First(); // Get a product for this example. Product p = mgr.FindEntities<Product>(EntityState.Unchanged).First(); // Now retrieve an object graph for the selected product. var roots = new List<Entity> { p }; // Add spans - we want any order details using this product, their orders, and the employees. // Note you must be able to "walk" all relations in the single EntitySpan, if you can't then // you should use additional EntitySpans. EntitySpan span1 = new EntitySpan(typeof(Product), EntityRelations.FK_Order_Details_Products, EntityRelations.FK_Order_Details_Orders, EntityRelations.FK_OrderSummary_Employee); var spans = new List<EntitySpan> { span1 }; // Get the entity graph var entityGraph = mgr.FindEntityGraph(roots, spans, EntityState.Unchanged); }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2